import 'package:enterprise_v6_app/app/components/common/no_permissions_widget.dart';
import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/data/entities/application/apply_bean.dart';
import 'package:enterprise_v6_app/app/modules/application/double_prevention_page/double_prevention_controller.dart';

/// 双重预防
class DoublePreventionPage extends StatelessWidget {
  DoublePreventionPage({super.key});

  final controller = Get.put(DoublePreventionController());

  @override
  Widget build(BuildContext context) {
    if (controller.doublePreventionList.isEmpty) {
      return const NoPermissionsWidget();
    }
    return Scaffold(
      backgroundColor: AppColors.bg_color_grey,
      appBar: CustomAppBar(
        titleText: '双重预防',
      ),
      body: Container(
        color: AppColors.bg_color_grey,
        child: Column(
          children: controller.doublePreventionList.map(_item).toList(),
        ),
      ),
    );
  }
  Widget _item(ApplyBean bean) {
    return Container(
      margin: EdgeInsets.only(top: 24.w, left: 16.w, right: 16.w),
      padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 9.w, bottom: 9.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8),
      ),
      child: Row(
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                bean.name,
                style: TextStyle(
                  fontSize: 16.sp,
                  color: AppColors.font_color_black,
                  fontWeight: FontWeight.w500,
                ),
              ),
              AppGaps.vGap18,
              SvgPicture.asset(AppImages.icon_next_step),
            ],
          ),
          const Spacer(),
          SvgPicture.asset(bean.iconPath),
        ],
      ),
    ).click(() {
      final int i = controller.doublePreventionList.indexOf(bean);
      Get.toNamed(bean.routes, arguments: i);
    });
  }

}
